@using StsServerIdentity.Resources
@inject LocService SharedLocalizer
@model TwoFactorAuthenticationViewModel
@{
    ViewData["Title"] = @SharedLocalizer.GetLocalizedHtmlString("2FA_AUTHENTICATION_TITLE");
    ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication);
}

<h4>@ViewData["Title"]</h4>
@if (Model.Is2faEnabled)
{
    if (Model.RecoveryCodesLeft == 0)
    {
        <div class="alert alert-danger">
            <strong>@SharedLocalizer.GetLocalizedHtmlString("2FA_NO_CODES_LEFT")</strong>
            <p>@SharedLocalizer.GetLocalizedHtmlString("2FA_NO_CODES_LEFT_TEXT") <a asp-action="GenerateRecoveryCodesWarning">@SharedLocalizer.GetLocalizedHtmlString("GENERATE")</a></p>
        </div>
    }
    else if (Model.RecoveryCodesLeft == 1)
    {
        <div class="alert alert-danger">
            <strong>@SharedLocalizer.GetLocalizedHtmlString("2FA_ONE_CODES_LEFT")</strong>
            <p>@SharedLocalizer.GetLocalizedHtmlString("2FA_ONE_CODES_LEFT_TEXT")  You can generate a new set of recovery codes. <a asp-action="GenerateRecoveryCodes">@SharedLocalizer.GetLocalizedHtmlString("GENERATE")</a></p>
        </div>
    }
    else if (Model.RecoveryCodesLeft <= 3)
    {
        <div class="alert alert-warning">
            <strong>@SharedLocalizer.GetLocalizedHtmlString("2FA_N_CODES_LEFT", @Model.RecoveryCodesLeft.ToString())</strong>
            <p>@SharedLocalizer.GetLocalizedHtmlString("2FA_N_CODES_LEFT_TEXT") <a asp-action="GenerateRecoveryCodesWarning">@SharedLocalizer.GetLocalizedHtmlString("GENERATE")</a></p>
        </div>
    }

    <a asp-action="Disable2faWarning" class="btn btn-primary">@SharedLocalizer.GetLocalizedHtmlString("DISABLE_2FA_BUTTON")</a>
    <a asp-action="GenerateRecoveryCodesWarning" class="btn btn-primary">@SharedLocalizer.GetLocalizedHtmlString("RESET_RECOVERY_CODES")</a>
}

<h5>@SharedLocalizer.GetLocalizedHtmlString("AUTHENTICATOR_APP")</h5>
@if (!Model.HasAuthenticator)
{
    <a id="enable-authenticator"  asp-action="EnableAuthenticator" class="btn btn-primary">@SharedLocalizer.GetLocalizedHtmlString("2FA_AUTHENTICATION_ADD_AUTHENTICATOR_APP")</a>
}
else
{
    <a id="enable-authenticator" asp-action="EnableAuthenticator" class="btn btn-primary">@SharedLocalizer.GetLocalizedHtmlString("2FA_AUTHENTICATION_ADD_SETUP_APP")</a>
    <a id="reset-authenticator" asp-action="ResetAuthenticatorWarning" class="btn btn-primary">@SharedLocalizer.GetLocalizedHtmlString("2FA_AUTHENTICATION_ADD_RESET_APP")</a>
}

<br />
<br />

<a id="enable-fido2mfa" asp-action="Fido2Mfa" class="btn btn-primary">@SharedLocalizer.GetLocalizedHtmlString("FIDO2_ADD_A_KEY")</a>

@section Scripts {
    @await Html.PartialAsync("_ValidationScriptsPartial")
}
